package com.hang.mapstruct;

import com.hang.entity.Comment;
import com.hang.model.dto.request.CommentModelDTO;
import com.hang.model.vo.CommentInfoVO;
import org.mapstruct.Mapper;

import java.util.LinkedList;
import java.util.List;

/**
 * @author lyh
 * @date 2022/01/23
 */

@Mapper(componentModel = "spring")
public interface CommentMapStruct {

    default List<CommentInfoVO> commentListToCommentInfoVOList(List<Comment> commentList){
        List<CommentInfoVO> commentInfoVOList = new LinkedList<>();
        commentList.forEach(
                comment -> {
                    commentInfoVOList.add(commonToCommentInfoVO(comment));
                }
        );

        return commentInfoVOList;
    }

    CommentInfoVO commonToCommentInfoVO(Comment comment);

    Comment commonModelDTOToComment(CommentModelDTO commentModelDTO);
}